<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm2(){
		var objs = document.getElementsByName("id");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != 0 && objs[i].checked)sign = sign + 1;
		}
		if(sign <= 0){
			alert("请选择待操作的项！");
			return false;
		}else if(sign > 1){
			alert("只能选择一个待操作项！");
			return false;
		}
		return true;
	}

	function back(){
		window.location.href = "./systemService.do";
		window.location.target = "main";
	}
	
	function stopOnlineUser(){
		if(checkForm2()){
			var objs = document.getElementsByName("id");
			var id = 0;
			for(var i = 0; i < objs.length; i++){
				if(objs[i].value != 0 && objs[i].checked){
					id = objs[i].value;
					break;
				}
			}
			var isStop = document.getElementById("isStop_"+id);
			if(isStop.value != "" && isStop.value != 'admin'){
				document.onlineUserForm.action = "./systemService.do?action=stopOnlineUser&id="+id;
				document.onlineUserForm.target = "main";
				document.onlineUserForm.submit();
			}else{
				alert("admin不能被终止！");
			}
		}
		
	}
	
	function pageCustomer(flag){
		document.onlineUserForm.action = "./systemService.do?action=onlineUser&flag="+flag;
		document.onlineUserForm.target = "main";
		document.onlineUserForm.submit();
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			alert("操作成功！");
		}
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="onlineUserForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" colspan="2">在线用户</td>
					</tr>
					<tr>
						<td	valign="bottom" class="a_tools" style="padding-left: 3px;">
							<a class="closestage" href="javascript:stopOnlineUser();" hidefocus="true">终止</a>
						</td>
						<td align="right" valign="bottom">
							<a class="back" href="javascript:back();" title="返回" hidefocus="true">返回系统日志列表</a>&nbsp;&nbsp;
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">在线用户列表</td>
					</tr>
					<tr>
						<td>
							<table class="table">
								<tr>
									<td valign="top">
										<table class="table_style">
											<tr>
												<td class="title" width="8"></td>
												<td class="title" width="30">选择</td>
												<td class="title" width="">用户登录名</td>
												<td class="title" width="">用户姓名</td>
												<td class="title" width="">登录时间</td>
											</tr>
											<c:forEach var="user" items="${users}">
											<tr onmouseover="onmousemoveChange(this,'img${user.id}')" onmouseout="onmouseoutChange(this,'img${user.id}')">
												<td height="16" width="8" align="right"><img id="img${user.id}" src="./images/table_sign2.bmp"></td>
												<td>
													<input id="id" name="id" type="checkbox" value="${user.userId}"/>
													<input id="isStop_${user.userId}" name="isStop_${user.userId}" type="hidden" value="${user.userCode}"/>
												</td>
												<td>${user.userCode}</td>
												<td>${user.userName}</td>
												<td><fmt:formatDate value="${user.loginDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
											</tr>
											</c:forEach>
										</table>
									</td>
								</tr>
								<tr>
									<td>
										<!-- page -->
										<table class="table_page">
											<tr>
												<td class="a_tools">
													${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>&nbsp;&nbsp;
													<fmt:message key='common.page.totalPage'/>&nbsp;${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;&nbsp;
													<fmt:message key='common.page.current'/>&nbsp;${currentPage}&nbsp;<fmt:message key='common.page'/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													<a href="javascript:pageCustomer(1);" target="main" hidefocus="true"><fmt:message key='common.page.first'/></a>&nbsp;&nbsp;
													<a href="javascript:pageCustomer(2);" target="main" hidefocus="true"><fmt:message key='common.page.previous'/></a>&nbsp;&nbsp;
													<a href="javascript:pageCustomer(3);" target="main" hidefocus="true"><fmt:message key='common.page.next'/></a>&nbsp;&nbsp;
													<a href="javascript:pageCustomer(4);" target="main" hidefocus="true"><fmt:message key='common.page.last'/></a>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
</body>
</html>